﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Ample.Model;

namespace Ample.BLL.User
{
    public class UserBO
    {
        #region Get Methods

        public UserProfile GetUserProfileByUsername(string username)
        {
            return DAL.UserManager.Create().GetUserProfileByUsername(username);
        }

        public Model.User GetUserByUsername(string username)
        {
            return DAL.UserManager.Create().GetUserByUsername(username);
        }

        #endregion

        public void UpdateUserProfile(UserProfile userProfile)
        {
            OperationStatus opStatus = DAL.UserManager.Create().UpdateUserProfile(userProfile);
            if (!opStatus.Status)
            {
                throw new ApplicationException(String.Format("Error occurred in BLL.UserRules.UpdateUserProfile: {0}", opStatus.Exception.Message));
            }
        }

        public void InsertUserProfile(UserProfile userProfile)
        {
            OperationStatus opStatus = DAL.UserManager.Create().InsertUserProfile(userProfile);
            if (!opStatus.Status)
            {
                throw new ApplicationException(String.Format("Error occurred in BLL.UserRules.InsertUserProfile: {0}", opStatus.Exception.Message));
            }
        }

        public void SaveUserProfile(UserProfile userProfile)
        {
            OperationStatus opStatus = DAL.UserManager.Create().SaveUserProfile(userProfile);
            if (!opStatus.Status)
            {
                throw new ApplicationException(String.Format("Error occurred in BLL.UserRules.SaveUserProfile: {0}", opStatus.Exception.Message));
            }
        }

    }
}
